<template>
  <div>
    <ol class="breadcrumb">
      <li class="breadcrumb-item">系统管理</li>
      <li class="breadcrumb-item active">权限管理</li>
    </ol>
    <div class="bg-white px-3">
      <div class="layer-loading" v-show="loading"><i></i><i></i><i></i></div>

      <div class="text-muted py-3 pb-0">系统权限列表.</div>
      <div class="btn-group mr-sm-2 mb-3">
        <a class="btn btn-secondary" title="全部展开" @click="toggle('expandAll', $event)">展开</a>
        <a class="btn btn-secondary active" title="全部收缩" @click="toggle('collapseAll', $event)">收缩</a>
      </div>
      <router-link class="btn btn-outline-info rounded float-right" to="/permission/new"><i class="fa fa-plus"></i> 新增</router-link>

      <treelist :treenodes="treenodes"></treelist>
    </div>
  </div>
</template>
<script>
  import treelist from '../../widgets/treelist.vue'
  import {Permission} from '../../resources'
  import utils from '../../misc/utils'
  import swal from 'sweetalert'

  export default {
    data: () => ({
      loading: false,
      param: {
        name: ''
      },
      treenodes: []
    }),
    beforeRouteEnter(to, from, next) {
      Permission.tree().then(response => {
        next(vm => {
          vm.treenodes = response.data
          vm.$nextTick(() => vm.$emit('loaded'))
        })
      })
    },
    methods: {
      toggle(method, event) {
        var $this = $(event.target)
        $this.addClass('active').siblings().removeClass('active')
        this.$treetable.treetable(method)
      },
      del (id, index) {
      }
    },
    components: {treelist}
  }
</script>